package org.testmyapp.entities;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import org.testmyapp.persistence.BusinessObjectMarker;

@Entity
public class Claim implements BusinessObjectMarker {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3764570993823852431L;

	public static String tableName = "Claim";

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private int id;
	private String catalog;
	@ManyToOne
	@JoinColumn(name = "claimtype_id")
	private ClaimType claimType;
	private String identifier;
	private Integer baseSum;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getCatalog() {
		return catalog;
	}

	public void setCatalog(String catalog) {
		this.catalog = catalog;
	}

	public ClaimType getClaimType() {
		return claimType;
	}

	public void setClaimType(ClaimType claimType) {
		this.claimType = claimType;
	}

	public String getIdentifier() {
		return identifier;
	}

	public void setIdentifier(String identifier) {
		this.identifier = identifier;
	}

	public Integer getBaseSum() {
		return baseSum;
	}

	public void setBaseSum(Integer baseSum) {
		this.baseSum = baseSum;
	}

	public String toString() {
		String result = "";
		result += "Claim " + getIdentifier() + " (catalog " + getCatalog()
				+ ", claimtype: " + getClaimType() + ", basesum: "
				+ getBaseSum() + ")";
		return result;
	}

	public boolean equals(Object o) {
		if (o == this)
			return true;
		if (!(o instanceof Claim) || o == null)
			return false;
		Claim other = (Claim) o;
		if (this.getId() != other.getId()) {
			System.out.println("claimequals1");
			return false;
		}
		if ((this.getCatalog() == null && other.getCatalog() != null)
				|| !this.getCatalog().equals(other.getCatalog())) {
			System.out.println("claimequals2");
			return false;
		}
		if ((this.getIdentifier() == null && other.getIdentifier() != null)
				|| !this.getIdentifier().equals(other.getIdentifier())) {
			System.out.println("claimequals3");
			return false;
		}
		if ((this.getClaimType() == null && other.getClaimType() != null)
				|| !this.getClaimType().equals(other.getClaimType())) {
			System.out.println("claimequals4");
			return false;
		}
		if ((this.getBaseSum() == null && other.getBaseSum() != null)
				|| !this.getBaseSum().equals(other.getBaseSum())) {
			System.out.println("claimequals5");
			return false;
		}
		return true;
	}

}
